package com.lzh.oss.controller;

import com.lzh.commonutils.R;
import com.lzh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName FileUploadController
 * Description
 * @Author lizihao
 * Date 2020/11/26 16:17
 * @Version 1.0
 **/
@Api(description="阿里云文件管理")
@CrossOrigin //跨域
@RestController
@RequestMapping("/oss/file")
public class FileUploadController {

    @Autowired
    private FileService fileService;

    @PostMapping("upload")
    public R upload(@ApiParam(name = "file", value = "文件", required = true)
                    @RequestParam("file") MultipartFile file) {
        String upload = fileService.upload(file);
        return R.ok().message("文件上传成功").data("url",upload);
    }
}
